interface IUSB{
    void OpenDevice();
    void CloseDevice();
}
class Mouse implements IUSB{
    @Override
    public void OpenDevice() {
        System.out.println("打开鼠标！");
    }

    public void click(){
        System.out.println("鼠标点击！");
    }
    @Override
    public void CloseDevice() {
        System.out.println("关闭鼠标！");
    }
}

class KeyBoard implements IUSB{

    @Override
    public void OpenDevice() {
        System.out.println("打开键盘！");
    }
    public void input(){
        System.out.println("键盘输入！");
    }
    @Override
    public void CloseDevice() {
        System.out.println("关闭键盘！");
    }
}
class Computer{
    public void PowerOn() {
        System.out.println("打开计算机！");
    }
    public void PowerOff() {
        System.out.println("关闭计算机！");
    }
    public void UseDevice(IUSB iusb){
        iusb.OpenDevice();
        if (iusb instanceof Mouse){
            Mouse mouse = (Mouse)iusb;
            mouse.click();
        }else if (iusb instanceof KeyBoard){
            KeyBoard keyBoard = (KeyBoard) iusb;
            keyBoard.input();
        }
        iusb.CloseDevice();
    }
}

public class test {
    public static void main(String[] args) {
        Computer computer = new Computer();
        computer.PowerOn();
        //使用鼠标
        computer.UseDevice(new Mouse());
        computer.UseDevice(new KeyBoard());
        //使用电脑
        computer.PowerOff();
    }
}
